package com.gpj.learn.springcloud.common.config;

import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * @className ExtSpringMVC
 * @description TODO
 * @author GPJ
 * @date 2020/5/6 14:27
 * @version 1.0
 **/
@Configuration
public class ExtSpringMVC implements WebMvcRegistrations {
    @Override
    public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
        return new RequestMappingHandlerMapping() {
            @Override
            protected boolean isHandler(Class<?> beanType) {
                return (AnnotatedElementUtils.hasAnnotation(beanType, Controller.class)
                        && (AnnotatedElementUtils.hasAnnotation(beanType, RequestMapping.class) && !beanType.isInterface())
                );
            }
        };
    }
}
